package jgl.vajra.driver.part.mine.activity;

import com.google.android.flexbox.FlexDirection;
import com.google.android.flexbox.FlexWrap;
import com.google.android.flexbox.FlexboxLayoutManager;

import java.util.ArrayList;
import java.util.List;

import jgl.vajra.driver.R;
import jgl.vajra.driver.databinding.ActivityNicknamePageBinding;
import jgl.vajra.driver.part.mine.contract.NicknamePageContract;
import jgl.vajra.driver.part.mine.viewModel.NicknamePageViewModel;
import jgl.vajra.driver.widget.databindingadapter.SingleTypeBindingAdapter;
import jgl.vajra.driver.widget.mvvm.factory.CreateViewModel;
import jgl.vajra.driver.widget.mvvm.view.BaseMVVMActivity;
import jgl.vajra.driver.widget.utils.ToastUtils;

@CreateViewModel(NicknamePageViewModel.class)
public class NicknamePageActivity extends BaseMVVMActivity<NicknamePageViewModel, ActivityNicknamePageBinding> implements NicknamePageContract.View {
    @Override
    public int getLayoutId() {
        return R.layout.activity_nickname_page;
    }

    @Override
    public void initView() {
        super.initView();
        mBinding.setView(this);

        List<String> list=new ArrayList<>();
        list.add("王思聪");
        list.add("马云");
        list.add("马斯克");
        list.add("特朗普");
        list.add("奥巴马");
        list.add("比尔盖茨");
        list.add("拜登");
        list.add("王健林");
        list.add("马化腾");
        list.add("拉登");
        list.add("刘强东");

        // 不可嵌套滑动
        mBinding.recyclerView.setNestedScrollingEnabled(false);
        // 取消head 的 recycleView的焦点
        mBinding.recyclerView.setFocusableInTouchMode(false);

        FlexboxLayoutManager flManager = new FlexboxLayoutManager(this);
        flManager.setFlexWrap(FlexWrap.WRAP);
        //设置主轴的方向
        flManager.setFlexDirection(FlexDirection.ROW);
        //设置布局管理器
        mBinding.recyclerView.setLayoutManager(flManager);

        SingleTypeBindingAdapter adapter = new SingleTypeBindingAdapter(this, list, R.layout.item_city_choice);
        mBinding.recyclerView.setAdapter(adapter);
    }

    //保存
    @Override
    public void onDetermine() {
        ToastUtils.showShort("保存");
    }
}
